package com.xjgc.common.config;

import com.xjgc.ws.server.SapToMsi;
import com.xjgc.ws.server.impl.SapToMsiImpl;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;

import javax.xml.ws.Endpoint;

/**
 * Created by wxy on 2019/11/1.
 */
@Configuration
@ImportResource(locations= {"classpath:cxf-client.xml"})
public class CxfConfig {


    @Bean(name = Bus.DEFAULT_BUS_ID)
    public SpringBus springBus() {
        return new SpringBus();
    }

    @Bean
    public SapToMsi sapToMsi(){
        return new SapToMsiImpl();

    }

    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), sapToMsi());
        endpoint.publish("/sapToMsi");
//        endpoint.getInInterceptors().add(new WsInterceptor()); //add webservice inteceptor
        return endpoint;
    }

}
